<template>
    <el-menu
        :style="{ width : isCollapse ? '64px' :'220px' }"
        active-text-color="#ffd04b"
        background-color="#545c64"
        class="aside-container"
        default-active="2"
        text-color="#fff"
        @open="handleOpen"
        @close="handleClose"
        :collapse="isCollapse"
        :default-active="active"
    >
        <p class="logo-lg">{{ isCollapse?'DIDI':'DIDI陪诊' }}</p>
        <TreeMenu :menuData="menuData" :index="1"/>
    </el-menu>
</template>

<script setup>
import TreeMenu from '../components/treeMenu.vue';
import { useRouter } from 'vue-router';
import { reactive,computed } from 'vue';
import { useStore } from 'vuex';

const active=computed(()=>store.state.menu.menuActive);// 当前路由

const router=useRouter();// 路由实例

const store=useStore();// vuex实例

const isCollapse=computed(()=>store.state.menu.isCollapse);// 是否展开侧边栏

// console.log(JSON.parse(localStorage.getItem('pz_v3pz')).menu.routerList,'pz_v3pz');

const menuData=JSON.parse(localStorage.getItem('pz_v3pz')).menu.routerList;// 动态路由数据

const handleOpen=()=>{// 打开一个特定的子菜单，参数是要打开的子菜单的索引
    console.log('open');
};

const handleClose=()=>{// 关闭一个特定的子菜单，参数是要关闭子菜单的索引
    console.log('close');
};

</script>

<style lang="less" scoped>
    .aside-container {
        height: 100%;
        .logo-lg {
            color: white;
            text-align: center;
            font-size: 20px;
            line-height: 40px;
            font-weight: 600;
        }
    }
</style>